﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DLL;
using Public;

namespace QLBanVe
{
    public partial class frmAddSanBay : Form
    {
        public frmAddSanBay()
        {
            InitializeComponent();
        }
        ChuyenBayDLL cls = new ChuyenBayDLL();
        SanBayDLL sb = new SanBayDLL();
        private void btnThoat_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void frmAddSanBay_Load(object sender, EventArgs e)
        {
           
        }

        private void btnThem_Click(object sender, EventArgs e)
        {

            try
            {
                
                
                
                SanBayPublic p = new SanBayPublic();
                p.MaSanBay = txtMaSanBay.Text.Trim();
                p.TenSanBay = txtTenSanBay.Text.Trim();
                if (txtMaSanBay.Text == "" || txtTenSanBay.Text == "")
                    MessageBox.Show("Không được bỏ trống");
                else
                {
                    DataTable dt = new DataTable();
                    int ai = int.Parse(sb.ThemSanBay(p).ToString());
                    if (ai > 0)
                    {
                       
                        txtMaSanBay.Text = "";
                        txtTenSanBay.Text = "";
                    }
                    else MessageBox.Show("Thất bại");
                }
                
            }
            catch
            {
                MessageBox.Show("Mã đã tồn tại");
            }
        }

        private void frmAddSanBay_FormClosed(object sender, FormClosedEventArgs e)
        {
            frmNhanLichChuyenBay f = new frmNhanLichChuyenBay();
            f.Show();
        }
    }
}
